<template>
  <div>
    <van-search
      v-model="searchValue"
      placeholder="请输入搜索公司名称"
      shape="round"
      @search="onSearch"
      @cancel="onCancel"
    />
    <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
      <zw-list
        v-for="(item,index) in listData"
        :key="index"
        pageName="visitRecord"
        :configData="item"
        @goToDetail="goToDetail"
        @confirm="confirm"
        @questionReport="questionReport"
      ></zw-list>
    </van-list>
  </div>
</template>

<script>
export default {
  data() {
    return {
      searchValue: "",
      listData: [],
      loading: false,
      finished: false,
      queryData: {
        pageSize: 10,
        pageNo: 1,
        dataCheck:true,
      },
    };
  },
  created() {},
  methods: {
    getList() {
      this.$api
        .record({ method: "post", type: "datagrid" }, this.queryData)
        .then((res) => {
          this.listData.push(...res.data.data);
          if (this.listData.length == res.data.total)
            return (this.finished = true);
          this.queryData.pageNo++;
          this.loading = false;
        });
    },
    onLoad() {
      this.getList();
    },
    onSearch() {
      this.queryData.pageNo = 1;
      this.queryData.name = this.searchValue;
      this.finished = false
      this.loading = true
      this.listData = []
      this.onLoad()
    },
    onCancel() {},
    goToDetail(name, id) {
      this.$router.push({ name: "companyInvestigation", params: { id } ,query:{name}});
    },
    confirm(title) {
      this.$router.push({ name: "visitOpinion", params: { title } });
    },
    questionReport(title) {
      this.$router.push({ name: "questionReport", params: { title } });
    },
  },
};
</script>

<style scoped lang="less">
</style>
